// pages/user/user-balance/index.js
const app = getApp()

Page({
    /**
     * 页面的初始数据
     */
    data: {
        CustomBar: app.globalData.CustomBar,
        theme: app.globalData.theme, //全局颜色变量
        goodsCategory: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        app.initPage()
            .then(res => {
                this.goodsCategoryGet()
            })
    },
    goodsCategoryGet() {
        app.api.goodsCategoryGet()
            .then(res => {
                let goodsCategory = res.data || []
                if (goodsCategory.length > 0) {
                    // 获取师傅信息
                    app.api.providerInfoGet().then(res1 => {
                        let data = res1.data || {}
                        let goodsCategorys = data.goodsCategorys
                        goodsCategory.forEach((v, i) => {
                            v['checked'] = goodsCategorys.indexOf(v.id) >= 0;
                            goodsCategory[i] = v;
                        })
                        this.setData({
                            goodsCategory: goodsCategory
                        })
                    })
                }
            })
    },
    checkboxChange(e) {
        console.log('checkbox发生change事件，携带value值为：', e.detail.value)
    },
    formSubmit: function (e) {
        const that = this
    },
})